package SV_CLASSDEF_INJ;

import javax.servlet.ServletRequest;
import java.security.SecureClassLoader;

public class Vulnerable {
    private class LocalLoader extends SecureClassLoader {

        public Class<?> createClass(String name, byte[] b, int off, int len) {
            return defineClass(name, b, off, len);
        }
    }



    public Class<?> createClassData(final ServletRequest req) {
        final String classData = req.getParameter("class.data");
        final byte[] bytes = classData.getBytes();

        final TestLoader loader = new TestLoader();
        Class<?> newClass = loader.createClass("name", bytes, 0, bytes.length);
        return newClass;
    }
}
